// 1.导入 express
const express = require('express');

const { singers } = require('./singers.json');


// 2.创建应用对象
const app = express();

// 3.创建路由
app.get('/singer/:id', (req, res) => {
  // 获取路由参数
  let { id } = req.params;
  let result = singers.find(item => item.id === id * 1);
  console.log(result);
  res.end('success');
});

// 4.监听端口，启动服务
app.listen(9000, () => {
  console.log('服务器启动成功');
});